package studen;


import java.util.ArrayList;

public class StudentText {
    public static void main(String[] args) {
        Student a =new Student();
        a.setId(1);
        a.setName("张三");

        Student b =new Student();
        b.setId(2);
        b.setName("李四");

        Student c =new Student();
        c.setId(3);
        c.setName("王五");

        ArrayList<Student> list = new ArrayList<>();
        list.add(a);
        list.add(b);
        list.add(c);

        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println("---------------------------------");
        for (int i = 0; i < list.size(); i++) {

            if (list.get(i).getName().equals("张三")){

                list.get(i).setName("张三丰");
            }
        }

        for (int i = 0; i < list.size(); i++) {

            if (list.get(i).getName().equals("王五")){

                list.remove(i);
            }
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }

}
